package presentationTier.actions;

import businessTier.IMovieFacade;
import businessTier.MovieFacade;
import core.Movie;
import core.MovieException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import presentationTier.Global;
import presentationTier.MainForm;
import presentationTier.MovieTableModel;


/**
 *
 * @author vojta
 */
public class DeleteMovieAction implements ActionListener{

    MainForm form;

    public DeleteMovieAction(MainForm aThis) {
        form = aThis;
    }

    public void actionPerformed(ActionEvent e) {
        try {
            MovieTableModel model = (MovieTableModel) form.jTable1.getModel();
            Movie movie = model.getMovieAt(form.jTable1.getSelectedRow());
            IMovieFacade mf = MovieFacade.getInstance();
            mf.removeMovie(movie);

            Global.refreshTable(form);
            
        } catch (MovieException ex) {
            ex.printStackTrace();
        }

    }

}
